package www.wen.com.common.lib.base.module

import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import www.wen.com.common.lib.data.entities.LoadingDialog
import www.wen.com.common.lib.data.entities.LoadingHelperUiState
import www.wen.com.common.lib.data.entities.UiStateCustom

/**
 * @author WEN
 * @Description:
 * @date 2020/11/2 17:35
 */
open class BaseViewModel @ViewModelInject constructor() : ViewModel(), LifecycleObserver {

    val loading = MutableLiveData<UiStateCustom<LoadingDialog<String>>>()

    val loadingUiHelper = MutableLiveData<LoadingHelperUiState>()

    open class UiState<T>(
        val isLoading: Boolean = false,
        val isRefresh: Boolean = false,
        val isSuccess: T? = null,
        val isError: String? = null,
        val showTip: String? = "正在加载中"
    )

    open class BaseUiModel<T>(
        var showLoading: Boolean = false,
        var showError: String? = null,
        var showSuccess: T? = null,
        var showEnd: Boolean = false, // 加载更多
        var isRefresh: Boolean = false // 刷新
    )

}